:root {
  color-scheme: light;
  --bg: #f8fafc;
  --panel: #ffffff;
  --panel-strong: #111827;
  --text: #1f2937;
  --muted: #6b7280;
  --line: #e5e7eb;
  --accent: #0f766e;
  --accent-strong: #115e59;
  --green: #22c55e;
  --blue: #2563eb;
  --rose: #e11d48;
  --shadow: 0 16px 40px rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 24px;
  background: #101827;
  color: #f9fafb;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
}

.brand-mark {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border-radius: 8px;
  background: #f9fafb;
  color: #101827;
  font-weight: 800;
}

.brand strong,
.brand span {
  display: block;
}

.brand span {
  margin-top: 3px;
  color: #cbd5e1;
  font-size: 13px;
}

.primary-action {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  background: var(--green);
  color: #052e16;
  font-weight: 800;
}

.primary-action span {
  font-size: 20px;
  line-height: 1;
}

.nav-list {
  display: grid;
  gap: 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: #d1d5db;
  text-align: left;
}

.nav-item:hover,
.nav-item.active {
  border-color: rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
}

.nav-item span {
  display: grid;
  width: 22px;
  height: 22px;
  place-items: center;
  color: #93c5fd;
}

.sync-panel {
  margin-top: auto;
  padding: 16px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
}

.sync-panel div {
  display: flex;
  gap: 8px;
  align-items: center;
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: var(--green);
  box-shadow: 0 0 0 5px rgba(34, 197, 94, 0.16);
}

.sync-panel p {
  margin: 10px 0 0;
  color: #cbd5e1;
  font-size: 13px;
  line-height: 1.55;
}

.workspace {
  min-width: 0;
  padding: 22px;
}

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

.search-box {
  display: flex;
  flex: 1;
  align-items: center;
  gap: 10px;
  min-width: 0;
  min-height: 46px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.04);
}

.search-box span {
  color: var(--muted);
  font-size: 22px;
}

.search-box input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  color: var(--text);
}

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

.icon-button,
.toolbar-button {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
}

.auth-button {
  min-height: 42px;
  max-width: 180px;
  padding: 0 12px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.auth-screen {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 20px;
  background: #f8fafc;
}

.auth-screen[hidden] {
  display: none;
}

.auth-panel {
  width: min(420px, 100%);
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: var(--shadow);
}

.auth-panel h1 {
  margin: 18px 0 8px;
  color: var(--panel-strong);
}

.auth-panel p {
  margin: 0 0 18px;
  color: var(--muted);
  line-height: 1.5;
}

.google-login {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  border-radius: 8px;
  background: var(--panel-strong);
  color: #ffffff;
  font-weight: 800;
  text-decoration: none;
}

.icon-button:hover,
.toolbar-button:hover,
.toolbar-button.active {
  border-color: #99f6e4;
  background: #ccfbf1;
  color: var(--accent-strong);
}

.toolbar-button.danger:hover {
  border-color: #fecdd3;
  background: #ffe4e6;
  color: var(--rose);
}

.daily-strip {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(260px, 0.8fr);
  gap: 16px;
  align-items: center;
  margin: 18px 0;
  padding: 18px 20px;
  border-radius: 8px;
  background: #ecfeff;
  border: 1px solid #a5f3fc;
}

.daily-strip p,
.panel-heading p,
.integration-card p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.daily-strip strong {
  display: block;
  margin-top: 6px;
  color: #164e63;
  font-size: clamp(20px, 2vw, 30px);
  line-height: 1.2;
}

.daily-strip span {
  display: block;
  margin-top: 5px;
  color: #155e75;
  font-size: 16px;
}

.daily-strip em {
  display: block;
  margin-top: 4px;
  color: #475569;
  font-size: 14px;
  font-style: normal;
}

.daily-strip > div:last-child {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: flex-end;
}

.small-button {
  min-height: 38px;
  padding: 0 12px;
  border: 0;
  border-radius: 8px;
  background: #0e7490;
  color: #ffffff;
  font-weight: 700;
  white-space: nowrap;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(300px, 390px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.memo-list-panel,
.editor-panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.memo-list-panel {
  overflow: hidden;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.panel-heading h1,
.panel-heading h2 {
  margin: 4px 0 0;
  color: var(--panel-strong);
  line-height: 1.1;
}

.panel-heading h1 {
  font-size: 24px;
}

.panel-heading h2 {
  font-size: 18px;
}

.panel-heading > span {
  display: grid;
  min-width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 999px;
  background: #eef2ff;
  color: #3730a3;
  font-weight: 800;
}

.panel-heading.compact {
  padding: 0 0 14px;
  border: 0;
}

.memo-list {
  display: grid;
  gap: 8px;
  max-height: calc(100vh - 230px);
  overflow: auto;
  padding: 12px;
}

.memo-card {
  width: 100%;
  min-height: 122px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: inherit;
  text-align: left;
}

.memo-card:hover,
.memo-card.active {
  border-color: #5eead4;
  background: #f0fdfa;
}

.memo-card-top {
  display: flex;
  gap: 10px;
  align-items: baseline;
  justify-content: space-between;
}

.memo-card strong {
  min-width: 0;
  overflow: hidden;
  color: var(--panel-strong);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.memo-card-top span {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 12px;
}

.memo-card p {
  display: -webkit-box;
  margin: 9px 0 12px;
  overflow: hidden;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.memo-card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.memo-card-tags span {
  padding: 3px 7px;
  border-radius: 999px;
  background: #f1f5f9;
  color: #475569;
  font-size: 12px;
}

.empty-state {
  display: grid;
  min-height: 220px;
  place-items: center;
  color: var(--muted);
}

.editor-panel {
  padding: 18px;
}

.editor-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) repeat(3, 42px);
  gap: 8px;
  align-items: center;
}

.title-input,
.tag-input,
.body-input {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--text);
  outline: 0;
}

.title-input:focus,
.tag-input:focus,
.body-input:focus {
  border-color: #2dd4bf;
  box-shadow: 0 0 0 4px rgba(45, 212, 191, 0.14);
}

.title-input {
  min-height: 42px;
  padding: 0 12px;
  font-size: 20px;
  font-weight: 800;
}

.body-input {
  min-height: 360px;
  margin-top: 12px;
  padding: 16px;
  resize: vertical;
  line-height: 1.6;
}

.meta-row {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-top: 12px;
}

.tag-input {
  min-height: 40px;
  padding: 0 12px;
}

.meta-row span {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 13px;
}

.link-preview {
  display: grid;
  gap: 8px;
  margin-top: 12px;
  padding: 14px;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  background: #eff6ff;
}

.link-preview strong {
  color: #1d4ed8;
}

.link-preview a {
  overflow-wrap: anywhere;
  color: var(--blue);
  text-decoration: none;
}

.integration-panel {
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

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

.integration-card {
  min-height: 112px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fafafa;
}

.integration-card div {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
}

.integration-card strong {
  color: var(--panel-strong);
}

.integration-card span {
  padding: 3px 7px;
  border-radius: 999px;
  background: #dcfce7;
  color: #166534;
  font-size: 12px;
  white-space: nowrap;
}

.integration-card p {
  margin-top: 10px;
  line-height: 1.45;
}

.allowed-email-card {
  grid-column: 1 / -1;
}

.allowed-email-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 72px;
  gap: 8px;
  margin-top: 12px;
}

.allowed-email-form input,
.allowed-email-form button,
.allowed-email-list button {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.allowed-email-form input {
  min-width: 0;
  padding: 0 10px;
}

.allowed-email-form button,
.allowed-email-list button {
  background: #111827;
  color: #ffffff;
  font-weight: 700;
}

.allowed-email-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.allowed-email-list div {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
  border-top: 1px solid var(--line);
}

.allowed-email-list span {
  min-width: 0;
  overflow-wrap: anywhere;
  color: var(--text);
  font-size: 13px;
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 2;
    padding: 14px;
  }

  .brand,
  .sync-panel {
    display: none;
  }

  .nav-list {
    display: flex;
    overflow-x: auto;
  }

  .nav-item {
    flex: 0 0 auto;
  }

  .content-grid,
  .daily-strip {
    grid-template-columns: 1fr;
  }

  .daily-strip > div:last-child {
    justify-content: space-between;
  }

  .memo-list {
    max-height: 340px;
  }
}

@media (max-width: 640px) {
  .workspace {
    padding: 12px;
  }

  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar-actions {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
  }

  .icon-button {
    width: 100%;
  }

  .daily-strip,
  .editor-panel,
  .memo-list-panel {
    box-shadow: none;
  }

  .editor-toolbar {
    grid-template-columns: 1fr repeat(3, 40px);
  }

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

  .body-input {
    min-height: 300px;
  }
}
