:root {
  color-scheme: light;
  --page: #eef3f1;
  --surface: #fbfdfc;
  --surface-soft: #f4f7f5;
  --ink: #172321;
  --muted: #6e7c78;
  --line: rgba(28, 57, 50, 0.11);
  --brand: #12675a;
  --brand-deep: #0b4d43;
  --accent: #d4563c;
  --danger: #b73636;
  --success: #277358;
  --warning: #9b6318;
  --shadow: 0 18px 46px rgba(30, 62, 54, 0.1);
}

* {
  box-sizing: border-box;
}

html {
  background: var(--page);
  -webkit-text-size-adjust: 100%;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font-family:
    "PingFang SC",
    "Microsoft YaHei",
    system-ui,
    -apple-system,
    sans-serif;
  letter-spacing: 0;
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button {
  cursor: pointer;
}

.is-hidden {
  display: none !important;
}

.login-view {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
}

.login-panel {
  width: min(100%, 420px);
  padding: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.login-mark {
  position: relative;
  width: 54px;
  height: 54px;
  margin-bottom: 26px;
  border: 1px solid rgba(18, 103, 90, 0.12);
  border-radius: 8px;
  background: #e5f0ec;
}

.login-mark span {
  position: absolute;
  display: block;
  width: 19px;
  height: 19px;
  border-radius: 50%;
}

.login-mark span:nth-child(1) {
  top: 9px;
  left: 10px;
  background: #23a8c6;
}

.login-mark span:nth-child(2) {
  top: 13px;
  right: 9px;
  background: #8636c5;
}

.login-mark span:nth-child(3) {
  bottom: 8px;
  left: 18px;
  background: var(--accent);
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 750;
  letter-spacing: 0;
}

h1,
h2,
p {
  margin-top: 0;
}

.login-panel h1,
.topbar h1 {
  margin-bottom: 28px;
  font-size: 25px;
  line-height: 1.2;
}

.login-panel label,
.settings-grid label,
.field-label {
  color: #44534f;
  font-size: 12px;
  font-weight: 650;
}

.login-panel label {
  display: block;
  margin-bottom: 8px;
}

.login-fields {
  display: grid;
  gap: 8px;
}

.login-fields label:not(:first-child) {
  margin-top: 8px;
}

input,
select,
textarea {
  width: 100%;
  min-height: 40px;
  padding: 8px 11px;
  border: 1px solid rgba(30, 69, 60, 0.15);
  border-radius: 6px;
  outline: none;
  background: #f9fcfb;
  color: var(--ink);
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(18, 103, 90, 0.58);
  box-shadow: 0 0 0 3px rgba(18, 103, 90, 0.09);
}

textarea {
  resize: vertical;
  line-height: 1.55;
}

.login-button,
.primary-button {
  min-height: 40px;
  border: 0;
  border-radius: 6px;
  background: var(--brand);
  color: #f6fbf9;
  font-weight: 700;
}

.login-button {
  width: 100%;
  margin-top: 16px;
}

.login-button:hover,
.primary-button:hover:not(:disabled) {
  background: var(--brand-deep);
}

.form-message {
  min-height: 20px;
  margin: 12px 0 0;
  color: var(--danger);
  font-size: 12px;
}

.manage-view {
  min-height: 100vh;
  padding-bottom: 92px;
}

.topbar {
  display: flex;
  min-height: 82px;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 18px max(24px, calc((100vw - 1120px) / 2));
  border-bottom: 1px solid var(--line);
  background: rgba(251, 253, 252, 0.96);
}

.topbar h1 {
  margin: 0;
  font-size: 21px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.preview-link,
.quiet-button,
.secondary-button,
.icon-button,
.small-button {
  display: inline-flex;
  min-height: 36px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: #3e514c;
  font-size: 13px;
  font-weight: 650;
  text-decoration: none;
}

.preview-link,
.quiet-button,
.secondary-button {
  padding: 7px 13px;
}

.quiet-button:hover,
.preview-link:hover,
.secondary-button:hover,
.small-button:hover,
.icon-button:hover {
  border-color: rgba(18, 103, 90, 0.28);
  background: #eef6f2;
  color: var(--brand-deep);
}

.workspace {
  width: min(calc(100% - 48px), 1120px);
  margin: 0 auto;
}

.settings-section,
.entries-section {
  padding: 32px 0;
}

.settings-section {
  border-bottom: 1px solid var(--line);
}

.section-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 20px;
}

.section-heading h2 {
  margin: 0;
  font-size: 18px;
  line-height: 1.3;
}

.section-index {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 800;
}

.revision-label {
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

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

.settings-grid label {
  display: grid;
  gap: 7px;
}

.wide-field {
  grid-column: 1 / -1;
}

.entries-list {
  display: grid;
  gap: 14px;
}

.empty-editor {
  padding: 48px 20px;
  border: 1px dashed rgba(30, 69, 60, 0.2);
  border-radius: 8px;
  background: rgba(251, 253, 252, 0.6);
  color: var(--muted);
  text-align: center;
}

.entry-editor {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 7px 22px rgba(30, 62, 54, 0.055);
  overflow: hidden;
}

.editor-heading {
  display: flex;
  min-height: 54px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px 10px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-soft);
}

.editor-title {
  min-width: 0;
  margin: 0;
  overflow: hidden;
  font-size: 15px;
  line-height: 1.3;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.editor-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 5px;
}

.icon-button {
  width: 34px;
  height: 34px;
  min-height: 34px;
  padding: 0;
  font-size: 16px;
}

.icon-button:disabled {
  cursor: not-allowed;
  opacity: 0.35;
}

.icon-button.danger {
  color: var(--danger);
}

.editor-body {
  display: grid;
  gap: 22px;
  padding: 18px;
}

.base-fields {
  display: grid;
  grid-template-columns: 90px minmax(140px, 1.5fr) minmax(120px, 1fr) 150px;
  gap: 12px;
}

.base-fields .content-field {
  grid-column: 1 / -1;
}

.base-fields label,
.group-field {
  display: grid;
  gap: 6px;
}

.data-editor {
  border-top: 1px solid var(--line);
  padding-top: 18px;
}

.data-editor-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.data-editor-heading h4 {
  margin: 0;
  font-size: 14px;
}

.group-list {
  display: grid;
  border-top: 1px solid rgba(28, 57, 50, 0.07);
}

.group-row {
  display: grid;
  grid-template-columns: minmax(90px, 0.55fr) 110px minmax(180px, 1.8fr) 34px;
  align-items: end;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid rgba(28, 57, 50, 0.07);
}

.small-button {
  min-height: 32px;
  padding: 5px 10px;
}

.remove-group {
  width: 34px;
  height: 40px;
  padding: 0;
  color: var(--danger);
  font-size: 17px;
}

.save-dock {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 10;
  display: flex;
  min-height: 68px;
  align-items: center;
  justify-content: flex-end;
  gap: 18px;
  padding: 12px max(24px, calc((100vw - 1120px) / 2));
  border-top: 1px solid var(--line);
  background: rgba(251, 253, 252, 0.97);
  box-shadow: 0 -8px 30px rgba(30, 62, 54, 0.07);
}

.save-message {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.save-message.error {
  color: var(--danger);
}

.save-message.success {
  color: var(--success);
}

.save-message.warning {
  color: var(--warning);
}

.primary-button {
  min-width: 112px;
  padding: 8px 18px;
}

.primary-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.password-dialog {
  width: min(calc(100% - 32px), 440px);
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow);
}

.password-dialog::backdrop {
  background: rgba(14, 25, 23, 0.48);
}

.password-dialog form {
  display: grid;
  gap: 8px;
  padding: 28px;
}

.password-dialog label {
  margin-top: 7px;
  color: #44534f;
  font-size: 12px;
  font-weight: 650;
}

.dialog-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 4px;
}

.dialog-heading h2 {
  margin: 0;
  font-size: 20px;
}

.dialog-heading .icon-button {
  width: 36px;
  padding: 0;
  font-size: 18px;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 4px;
}

@media (max-width: 760px) {
  .topbar {
    padding: 15px 16px;
  }

  .topbar .eyebrow {
    display: none;
  }

  .topbar h1 {
    font-size: 18px;
  }

  .workspace {
    width: calc(100% - 28px);
  }

  .settings-section,
  .entries-section {
    padding: 24px 0;
  }

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

  .wide-field {
    grid-column: auto;
  }

  .base-fields {
    grid-template-columns: 74px minmax(0, 1fr);
  }

  .base-fields label:nth-child(3),
  .base-fields label:nth-child(4) {
    grid-column: span 1;
  }

  .group-row {
    grid-template-columns: minmax(0, 1fr) 96px 34px;
  }

  .group-field.values-field {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  .remove-group {
    grid-column: 3;
    grid-row: 1;
  }

  .save-dock {
    padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
  }
}

@media (max-width: 480px) {
  .login-view {
    padding: 14px;
  }

  .login-panel {
    padding: 28px 20px;
  }

  .preview-link {
    display: none;
  }

  .topbar-actions {
    gap: 5px;
  }

  .topbar-actions .quiet-button {
    padding-right: 9px;
    padding-left: 9px;
  }

  .password-dialog form {
    padding: 22px 18px;
  }

  .base-fields {
    grid-template-columns: 1fr 1fr;
  }

  .base-fields label:nth-child(2) {
    grid-column: 2;
  }

  .base-fields label:nth-child(3),
  .base-fields label:nth-child(4) {
    grid-column: 1 / -1;
  }

  .editor-heading {
    padding-left: 14px;
  }

  .editor-body {
    padding: 14px;
  }

  .section-heading {
    align-items: center;
  }

  .save-message {
    max-width: calc(100vw - 160px);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}
