* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0;
  font-family: "Alegreya Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic", system-ui, sans-serif;
  color: #eef5ff;
  background:
    radial-gradient(circle at top, rgba(51, 84, 128, 0.35), transparent 38%),
    linear-gradient(180deg, #07111f 0%, #0a1628 52%, #06101c 100%);
}

.history-app {
  width: min(1180px, calc(100vw - 32px));
  min-height: 100vh;
  margin: 0 auto;
  padding: 28px 0 32px;
  display: grid;
  grid-template-rows: auto auto 1fr;
  gap: 16px;
}

.history-header,
.toolbar,
.history-main {
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(10, 18, 31, 0.82);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.22);
  backdrop-filter: blur(18px);
}

.history-header {
  border-radius: 22px;
  padding: 22px 24px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.eyebrow {
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(148, 191, 255, 0.78);
}

.history-header h1 {
  margin: 6px 0 4px;
  font-size: clamp(28px, 4vw, 42px);
  line-height: 1;
}

.subtitle {
  margin: 0;
  font-size: 14px;
  color: rgba(206, 221, 246, 0.84);
}

.header-actions,
.detail-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.ghost-link,
.ghost-btn {
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(30, 47, 73, 0.76);
  color: #eff5ff;
  border-radius: 999px;
  min-height: 42px;
  padding: 0 16px;
  font: inherit;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 140ms ease, background 140ms ease, border-color 140ms ease;
}

.ghost-btn.accent {
  background: linear-gradient(180deg, rgba(38, 86, 71, 0.96), rgba(21, 58, 49, 0.96));
  border-color: rgba(112, 238, 197, 0.28);
}

.ghost-link:hover,
.ghost-btn:hover {
  transform: translateY(-1px);
  background: rgba(40, 61, 93, 0.92);
}

.ghost-btn:disabled {
  opacity: 0.48;
  cursor: default;
  transform: none;
}

.toolbar {
  border-radius: 18px;
  padding: 14px 18px;
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 14px;
}

.search-wrap {
  display: grid;
  gap: 6px;
  width: min(440px, 100%);
  font-size: 12px;
  color: rgba(197, 214, 242, 0.9);
}

.search-wrap input {
  width: 100%;
  min-height: 44px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(7, 13, 23, 0.84);
  color: inherit;
  padding: 0 14px;
  font: inherit;
}

.summary-text {
  font-size: 13px;
  color: rgba(179, 201, 236, 0.86);
}

.history-main {
  min-height: 0;
  border-radius: 24px;
  padding: 16px;
  display: grid;
  grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
  gap: 16px;
}

.history-list-panel,
.history-detail-panel {
  min-height: 0;
}

.history-list {
  height: 100%;
  min-height: 0;
  overflow: auto;
  display: grid;
  gap: 10px;
  padding-right: 2px;
}

.history-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: start;
}

.history-item-main {
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(14, 24, 40, 0.88);
  color: inherit;
  border-radius: 16px;
  padding: 14px;
  text-align: left;
  cursor: pointer;
  font: inherit;
  transition: border-color 140ms ease, background 140ms ease, transform 140ms ease;
}

.history-item-main:hover {
  transform: translateY(-1px);
  background: rgba(18, 32, 53, 0.96);
}

.history-item.is-selected .history-item-main {
  border-color: rgba(112, 238, 197, 0.42);
  background: linear-gradient(180deg, rgba(19, 41, 40, 0.96), rgba(12, 27, 32, 0.96));
}

.history-item-copy {
  min-height: 40px;
  padding-inline: 14px;
}

.history-time {
  font-size: 11px;
  color: rgba(173, 198, 237, 0.78);
  margin-bottom: 8px;
}

.history-text {
  font-size: 13px;
  line-height: 1.55;
  color: rgba(238, 244, 255, 0.96);
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.history-provider {
  margin-top: 10px;
  font-size: 11px;
  color: rgba(134, 164, 211, 0.82);
}

.history-empty {
  border-radius: 16px;
  border: 1px dashed rgba(255, 255, 255, 0.16);
  padding: 18px;
  color: rgba(193, 210, 238, 0.78);
  background: rgba(10, 18, 31, 0.44);
}

.history-detail-panel {
  display: grid;
  grid-template-rows: auto auto auto 1fr;
  gap: 14px;
}

.detail-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.detail-title {
  font-size: 22px;
  font-weight: 700;
}

.detail-meta {
  margin-top: 6px;
  font-size: 12px;
  line-height: 1.6;
  white-space: pre-line;
  color: rgba(186, 206, 238, 0.86);
}

.detail-grid {
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.detail-card {
  min-height: 0;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 10px;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(10, 18, 31, 0.72);
  padding: 14px;
}

.card-title {
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(143, 184, 239, 0.82);
}

.detail-text {
  margin: 0;
  min-height: 0;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  font: inherit;
  font-size: 14px;
  line-height: 1.65;
  color: rgba(241, 246, 255, 0.96);
}

.review-editor,
.dictionary-panel {
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(10, 18, 31, 0.78);
  padding: 16px;
}

.review-editor.hidden {
  display: none;
}

.editor-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.editor-title {
  font-size: 16px;
  font-weight: 700;
  color: rgba(241, 246, 255, 0.98);
}

.editor-status {
  margin-top: 4px;
  font-size: 12px;
  line-height: 1.6;
  color: rgba(183, 206, 240, 0.82);
  white-space: pre-wrap;
}

.editor-field {
  display: grid;
  gap: 8px;
  margin-top: 12px;
  font-size: 12px;
  color: rgba(197, 214, 242, 0.9);
}

.editor-inline-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.editor-input,
.editor-textarea {
  width: 100%;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(7, 13, 23, 0.84);
  color: inherit;
  padding: 12px 14px;
  font: inherit;
  resize: vertical;
}

.dictionary-toolbar {
  margin-bottom: 14px;
}

.dictionary-list {
  display: grid;
  gap: 10px;
}

.dictionary-item {
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(12, 24, 40, 0.82);
  padding: 14px;
}

.dictionary-item-title {
  font-size: 13px;
  font-weight: 700;
  color: rgba(239, 245, 255, 0.98);
}

.dictionary-item-instruction {
  margin-top: 6px;
  font-size: 13px;
  line-height: 1.6;
  color: rgba(223, 235, 255, 0.92);
  white-space: pre-wrap;
}

.dictionary-item-meta {
  margin-top: 8px;
  font-size: 11px;
  line-height: 1.5;
  color: rgba(157, 186, 228, 0.82);
}

@media (max-width: 900px) {
  .history-app {
    width: min(100vw, calc(100vw - 16px));
    padding: 10px 0 16px;
  }

  .history-header,
  .toolbar,
  .history-main {
    border-radius: 18px;
  }

  .history-header,
  .toolbar {
    padding: 14px;
  }

  .history-main {
    padding: 12px;
    grid-template-columns: 1fr;
  }

  .history-item {
    grid-template-columns: 1fr;
  }

  .history-item-copy {
    justify-self: end;
  }

  .detail-grid {
    grid-template-columns: 1fr;
  }

  .detail-head,
  .toolbar,
  .editor-head {
    flex-direction: column;
    align-items: stretch;
  }

  .editor-inline-grid {
    grid-template-columns: 1fr;
  }
}
