:root {
  --bg: #f3f5f8;
  --bg-strong: #eceff3;
  --panel: #ffffff;
  --panel-alt: #f8f9fb;
  --primary: #465a6d;
  --primary-strong: #2f3e4d;
  --primary-soft: #edf2f7;
  --header-bg: #1c2430;
  --header-bg-2: #232f3d;
  --header-text: #edf2f7;
  --text: #1a222d;
  --muted: #5d6777;
  --line: #dfe5ec;
  --line-strong: #c9d1db;
  --danger: #b64848;
  --danger-soft: #f8efef;
  --success: #2e5d4f;
  --success-soft: #edf5f1;
  --shadow: 0 14px 28px rgba(18, 24, 32, 0.08);
  --shadow-soft: 0 10px 22px rgba(18, 24, 32, 0.05);
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  font-family: "Inter", sans-serif;
  background: linear-gradient(180deg, var(--bg-strong) 0%, var(--bg) 100%);
  color: var(--text);
}

button, input, textarea, select {
  font: inherit;
}

button {
  cursor: pointer;
}

.auth-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(8px);
  z-index: 20;
}

.auth-card {
  width: min(100%, 430px);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: var(--shadow);
  padding: 28px 24px;
}

.auth-card h2 {
  margin-bottom: 18px;
  letter-spacing: -0.02em;
}

.auth-eyebrow {
  margin-bottom: 10px;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.auth-btn {
  width: 100%;
  margin-top: 8px;
}

.auth-error {
  margin: 10px 0 0;
  color: var(--danger);
  font-size: 0.82rem;
  font-weight: 600;
}

.app-shell {
  max-width: 1320px;
  margin: 0 auto;
  padding: 28px 18px 52px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
  padding: 18px 20px;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--header-bg) 0%, var(--header-bg-2) 100%);
  border: 1px solid rgba(255, 255, 255, 0.06);
  box-shadow: 0 12px 26px rgba(17, 28, 47, 0.18);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.task-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.eyebrow {
  margin: 0 0 7px;
  color: #d8e6ff;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 11px;
  font-weight: 800;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(2.1rem, 2vw + 1rem, 3rem);
  line-height: 1.1;
  letter-spacing: -0.04em;
  color: var(--header-text);
}

.layout {
  display: grid;
  grid-template-columns: minmax(320px, 420px) minmax(0, 1fr);
  gap: 24px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow-soft);
}

.form-panel {
  padding: 20px;
  background: linear-gradient(180deg, #ffffff 0%, #f9fafc 100%);
}

.field-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 18px;
}

.checkbox-row {
  margin-bottom: 10px;
}

.checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  color: var(--text);
  font-weight: 600;
}

.checkbox-label input {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
}

label {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--muted);
}

input[type="date"],
input[type="text"],
input[type="password"],
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 11px 14px;
  background: #fbfcff;
  color: var(--text);
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

input[type="date"]:focus,
input[type="text"]:focus,
input[type="password"]:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: rgba(45, 108, 223, 0.7);
  box-shadow: 0 0 0 4px rgba(45, 108, 223, 0.12);
  background: #fff;
}

textarea {
  resize: vertical;
  min-height: 140px;
}

.media-block {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: linear-gradient(180deg, var(--panel-alt), #edf4ff);
  padding: 14px;
  margin-top: 8px;
}

.media-header {
  margin-bottom: 12px;
  font-weight: 700;
  color: var(--text);
}

.media-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.upload-box,
.primary-btn,
.secondary-btn,
.ghost-btn,
.mini-btn {
  border-radius: 12px;
  border: 1px solid transparent;
  transition: transform 0.15s ease, box-shadow 0.2s ease, background 0.2s ease, border-color 0.2s ease;
}

.upload-box {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--primary-soft);
  color: var(--primary-strong);
  padding: 10px 14px;
  font-weight: 700;
  min-height: 44px;
  cursor: pointer;
  border-color: #d3e0fb;
}

.upload-box input {
  display: none;
}

.primary-btn,
.secondary-btn,
.ghost-btn {
  padding: 12px 18px;
  font-weight: 800;
}

.primary-btn {
  background: linear-gradient(180deg, var(--primary) 0%, var(--primary-strong) 100%);
  color: #fff;
  box-shadow: 0 10px 20px rgba(45, 108, 223, 0.2);
}

.primary-btn:hover,
.secondary-btn:hover,
.ghost-btn:hover,
.upload-box:hover,
.mini-btn:hover {
  transform: translateY(-1px);
}

.secondary-btn {
  background: #edf4ff;
  color: var(--primary-strong);
  border-color: #d4e0fb;
}

.ghost-btn {
  background: #fff;
  border-color: var(--line);
  color: var(--text);
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-top: 22px;
}

.media-preview {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}

.preview-item {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.8);
  border: 1px solid var(--line);
  border-radius: 12px;
}

.preview-item img {
  width: 100%;
  max-height: 220px;
  object-fit: cover;
  border-radius: 10px;
}

.preview-item audio {
  width: 100%;
}

.hidden {
  display: none !important;
}

.list-panel {
  padding: 20px;
  background: linear-gradient(180deg, #ffffff 0%, #f9fafc 100%);
}

.list-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.filter-boxes {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
}

.filter-box {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 170px;
}

.filter-box label {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.filter-box select {
  min-width: 180px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  background: #fbfcff;
  color: var(--text);
}

.note-list {
  display: grid;
  gap: 16px;
}

.note-card {
  background: linear-gradient(180deg, #ffffff 0%, #fafbfc 100%);
  border: 1px solid var(--line);
  border-left: 4px solid var(--primary);
  border-radius: 12px;
  padding: 16px 16px 14px;
  box-shadow: 0 8px 16px rgba(18, 24, 32, 0.03);
  transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

.note-card:hover {
  border-color: var(--line-strong);
  box-shadow: 0 10px 18px rgba(18, 24, 32, 0.06);
}

.note-card-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.note-date {
  margin-bottom: 6px;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  font-weight: 800;
}

.note-title {
  margin: 0;
  font-size: 1.26rem;
  letter-spacing: -0.02em;
}

.task-control {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: linear-gradient(180deg, #f8f9fb 0%, #f3f5f8 100%);
}

.task-toggle,
.task-date-control {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--text);
  font-weight: 700;
}

.task-toggle input,
.task-date-control input {
  accent-color: var(--primary);
}

.task-date-control input {
  width: auto;
  min-width: 160px;
}

.note-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: var(--success-soft);
  color: var(--success);
}

.completion-date-text {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.note-text {
  margin-bottom: 14px;
  white-space: pre-wrap;
  color: #2a3245;
  line-height: 1.6;
}

.note-media {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.note-image {
  max-width: 100%;
  border-radius: 12px;
  border: 1px solid var(--line);
}

.mini-btn {
  padding: 8px 12px;
  font-size: 0.75rem;
  font-weight: 800;
  background: #fff;
  border-color: var(--line);
  color: var(--text);
}

.danger-btn {
  color: var(--danger);
  border-color: rgba(182, 72, 72, 0.25);
  background: var(--danger-soft);
}

.empty-state {
  padding: 30px 20px;
  border: 1px dashed var(--line-strong);
  border-radius: 12px;
  background: #fafbfc;
  color: var(--muted);
  text-align: center;
  font-weight: 600;
}

body.read-only-mode .form-panel,
body.read-only-mode #exportBtn {
  display: none !important;
}

@media (max-width: 860px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .topbar {
    padding: 16px 18px;
  }

  .topbar,
  .list-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .header-actions {
    width: 100%;
    justify-content: space-between;
  }

  .filter-boxes {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr;
  }

  .filter-box,
  .filter-box input,
  .filter-box select {
    width: 100%;
  }
}

@media (max-width: 540px) {
  .app-shell {
    padding-inline: 12px;
    padding-top: 18px;
  }

  .form-panel,
  .list-panel {
    padding: 16px;
  }

  .header-actions {
    flex-direction: column;
    align-items: stretch;
    width: 100%;
  }

  .header-actions .primary-btn,
  .header-actions .ghost-btn {
    width: 100%;
  }

  .note-card-header {
    flex-direction: column;
  }

  .task-toggle,
  .task-date-control {
    align-items: flex-start;
    flex-direction: column;
  }

  .task-date-control input {
    width: 100%;
    min-width: 0;
  }
}
