:root {
  --bg: #f5f5f7;
  --surface: #ffffff;
  --text: #1d1d1f;
  --muted: #6e6e73;
  --border: #d2d2d7;
  --accent: #0071e3;
  --accent-hover: #0077ed;
  --danger: #c62828;
  --radius: 12px;
  --shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial,
    sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

#app {
  max-width: 1100px;
  margin: 0 auto;
  padding: 20px 20px 48px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.title {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.btn {
  border: none;
  border-radius: 999px;
  padding: 10px 18px;
  font-size: 0.95rem;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  font-weight: 600;
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid rgba(198, 40, 40, 0.35);
}

.btn-danger:hover {
  background: rgba(198, 40, 40, 0.06);
}

.toast {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 40;
  padding: 10px 18px;
  border-radius: 999px;
  background: #333;
  color: #fff;
  font-size: 0.9rem;
  box-shadow: var(--shadow);
}

.toast.error {
  background: #8b0000;
}

.layout {
  display: grid;
  grid-template-columns: minmax(280px, 380px) 1fr;
  gap: 20px;
  align-items: start;
}

@media (max-width: 800px) {
  .layout {
    grid-template-columns: 1fr;
  }
}

.sidebar,
.detail {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  min-height: 420px;
}

.sidebar {
  padding: 8px 10px 12px;
  overflow: hidden;
}

.detail {
  padding: 20px 22px 24px;
}

.empty-hint {
  padding: 32px 20px;
  text-align: center;
  color: var(--muted);
}

.empty-hint p {
  margin: 0.35em 0;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 0.85rem;
}

.item-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.item-row {
  list-style: none;
  padding: 0 0 10px;
  cursor: pointer;
}

.item-row:last-child {
  padding-bottom: 4px;
}

.item-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  background: var(--surface);
  transition: box-shadow 0.12s ease, border-color 0.12s ease;
}

.item-row:hover .item-card {
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.06);
}

.item-row.active .item-card {
  border-color: #b4d0ff;
  box-shadow: 0 0 0 2px rgba(0, 113, 227, 0.12);
}

.item-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  background: linear-gradient(180deg, #e8f1ff 0%, #dceaff 100%);
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
  min-height: 44px;
}

.item-title {
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.3;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #1a1a1a;
}

.item-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.item-times {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  font-size: 0.7rem;
  line-height: 1.25;
  color: #5f6368;
  max-width: 132px;
  text-align: right;
}

.item-time-done[hidden] {
  display: none !important;
}

.item-done-cb {
  width: 18px;
  height: 18px;
  cursor: pointer;
  flex-shrink: 0;
  accent-color: var(--accent);
}

.item-done-cb:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.item-body {
  padding: 12px 14px 14px;
  font-size: 0.9rem;
  line-height: 1.45;
  word-break: break-word;
  color: var(--text);
  min-height: 2.5em;
}

.item-card.completed .item-body {
  text-decoration: line-through;
  color: var(--muted);
}

.item-card.completed .item-title {
  color: var(--muted);
  text-decoration: line-through;
}

.item-meta {
  font-size: 0.72rem;
  color: var(--muted);
  margin-top: 6px;
}

.field {
  margin-bottom: 18px;
}

.field label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--muted);
}

.input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 0.95rem;
  font-family: inherit;
  resize: vertical;
  background: #fafafa;
}

.input:focus {
  outline: none;
  border-color: var(--accent);
  background: #fff;
}

.field-error {
  color: var(--danger);
  font-size: 0.85rem;
  margin: 6px 0 0;
}

.row-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 18px;
}

.check-wrap {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.95rem;
  cursor: pointer;
  user-select: none;
}

.footer-actions {
  margin-top: 8px;
  padding-top: 16px;
  border-top: 1px solid #ececec;
}

.drop-zone {
  border: 2px dashed var(--border);
  border-radius: 10px;
  padding: 20px;
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.drop-zone:focus {
  outline: none;
  border-color: var(--accent);
  background: #f3f8ff;
}

.drop-zone.dragover {
  border-color: var(--accent);
  background: #eef4ff;
}

.drop-zone.disabled {
  opacity: 0.5;
  pointer-events: none;
}

.thumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}

.thumb {
  position: relative;
  width: 88px;
  height: 88px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: #eee;
}

.thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  cursor: zoom-in;
  display: block;
}

.thumb-remove {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 22px;
  height: 22px;
  border: none;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
}

.thumb-remove:hover {
  background: rgba(0, 0, 0, 0.75);
}

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(0, 0, 0, 0.82);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.lightbox img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 4px;
}

.lightbox-close {
  position: absolute;
  top: 16px;
  right: 20px;
  border: none;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  font-size: 28px;
  line-height: 1;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  cursor: pointer;
}

.lightbox-close:hover {
  background: rgba(255, 255, 255, 0.28);
}

[hidden] {
  display: none !important;
}
