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51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
import gradio as gr
from datetime import datetime

def study_assistant(subject, goal, time_available, difficulty, learning_style, current_stress):
    if not subject or not goal or not time_available:
        return """

        <div class="result-card warning">

            <h3>Missing Information</h3>

            <p>Please fill in the subject, study goal, and time available.</p>

        </div>

        """

    try:
        minutes = int(time_available)
    except:
        return """

        <div class="result-card warning">

            <h3>Invalid Time</h3>

            <p>Please enter time available as a number, like 60.</p>

        </div>

        """

    if minutes < 30:
        plan = "Quick Focus Session"
        breakdown = [
            ("5 min", "Review key notes"),
            ("15 min", "Practice the hardest concept"),
            ("5 min", "Active recall without notes"),
            ("5 min", "Write down what still feels confusing")
        ]
    elif minutes <= 90:
        plan = "Balanced Study Session"
        breakdown = [
            ("10 min", "Review notes and identify weak areas"),
            ("25 min", "Study the main topic deeply"),
            ("25 min", "Practice questions or examples"),
            ("15 min", "Active recall / self-quiz"),
            ("10 min", "Summarize what you learned")
        ]
    else:
        plan = "Deep Study Session"
        breakdown = [
            ("15 min", "Warm-up review"),
            ("40 min", "Learn or relearn difficult material"),
            ("30 min", "Practice questions"),
            ("20 min", "Teach the concept out loud"),
            ("15 min", "Break"),
            ("30 min", "Final review + self-quiz")
        ]

    difficulty_advice = {
        "Easy": "Use this session to build speed and confidence.",
        "Medium": "Mix review with active practice so you do not just reread notes.",
        "Hard": "Start with the hardest topic first while your brain is fresh."
    }

    learning_methods = {
        "Visual": "Use diagrams, charts, color-coded notes, and concept maps.",
        "Practice-Based": "Focus on practice problems, quizzes, examples, and repetition.",
        "Verbal": "Explain the topic out loud like you are teaching someone.",
        "Reading/Writing": "Use active recall: close your notes and write what you remember."
    }

    stress_tips = {
        "Low": "You are in a good place to push for a productive session.",
        "Medium": "Use a timer so the session feels controlled and less overwhelming.",
        "High": "Start with a 2-minute reset. Focus on one small win first."
    }

    today = datetime.now().strftime("%B %d, %Y")

    timeline_html = ""
    for time, task in breakdown:
        timeline_html += f"""

        <div class="timeline-item">

            <div class="timeline-time">{time}</div>

            <div class="timeline-task">{task}</div>

        </div>

        """

    return f"""

    <div class="result-card">

        <div class="result-topline">Personalized Study Plan</div>



        <h2>{plan}</h2>



        <div class="summary-grid">

            <div>

                <span class="label">Date</span>

                <strong>{today}</strong>

            </div>

            <div>

                <span class="label">Subject</span>

                <strong>{subject}</strong>

            </div>

            <div>

                <span class="label">Goal</span>

                <strong>{goal}</strong>

            </div>

            <div>

                <span class="label">Time</span>

                <strong>{minutes} minutes</strong>

            </div>

        </div>



        <h3>Recommended Study Flow</h3>

        <div class="timeline">

            {timeline_html}

        </div>



        <div class="strategy-box">

            <h3>Best Strategy for You</h3>

            <p><strong>Difficulty:</strong> {difficulty} — {difficulty_advice[difficulty]}</p>

            <p><strong>Learning Style:</strong> {learning_style} — {learning_methods[learning_style]}</p>

            <p><strong>Stress Level:</strong> {current_stress} — {stress_tips[current_stress]}</p>

        </div>



        <div class="mission-box">

            <h3>Your Mission</h3>

            <ul>

                <li>Explain the main idea without looking at notes</li>

                <li>Answer practice questions with more confidence</li>

                <li>Identify what still needs review</li>

                <li>Create one clear next step for your next session</li>

            </ul>

        </div>

    </div>

    """

custom_css = """

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');



:root {

    --navy: #071A33;

    --navy-light: #0B2A50;

    --gold: #D4A017;

    --gold-soft: #FFF7DD;

    --cream: #F8F5EF;

    --text: #111827;

    --muted: #6B7280;

    --border: #E5E7EB;

}



body {

    background: radial-gradient(circle at top left, #EEF4FF 0, #F8F5EF 35%, #FFFFFF 100%) !important;

    font-family: 'Inter', sans-serif !important;

}



.gradio-container {

    max-width: 1220px !important;

    margin: auto !important;

    padding: 36px 20px !important;

}



#hero {

    background: linear-gradient(135deg, var(--navy) 0%, #102B52 60%, #163B6E 100%);

    color: white;

    padding: 44px 48px;

    border-radius: 28px;

    box-shadow: 0 24px 70px rgba(7, 26, 51, 0.22);

    margin-bottom: 28px;

    position: relative;

    overflow: hidden;

}



#hero::after {

    content: "";

    position: absolute;

    width: 320px;

    height: 320px;

    right: -90px;

    top: -110px;

    background: rgba(212, 160, 23, 0.18);

    border-radius: 50%;

}



.hero-badge {

    display: inline-block;

    background: rgba(255,255,255,0.12);

    border: 1px solid rgba(255,255,255,0.22);

    color: #FDE68A;

    padding: 8px 14px;

    border-radius: 999px;

    font-size: 13px;

    font-weight: 700;

    letter-spacing: 0.04em;

    text-transform: uppercase;

    margin-bottom: 18px;

}



.hero-title {

    font-size: 46px;

    line-height: 1.05;

    font-weight: 800;

    margin: 0 0 12px 0;

    max-width: 720px;



    color: #FFFFFF;

    text-shadow: 0px 2px 12px rgba(0,0,0,0.28);

}



.hero-subtitle {

    color: #DDE7F6;

    font-size: 18px;

    line-height: 1.6;

    max-width: 720px;

    margin: 0;

}



#main-panel {

    background: rgba(255,255,255,0.82);

    border: 1px solid rgba(229,231,235,0.9);

    backdrop-filter: blur(14px);

    border-radius: 28px;

    padding: 28px;

    box-shadow: 0 20px 55px rgba(15,23,42,0.08);

}



.input-card {

    background: white;

    border: 1px solid var(--border);

    border-radius: 24px;

    padding: 24px;

    box-shadow: 0 12px 35px rgba(15, 23, 42, 0.07);

}



.section-title {

    font-size: 22px;

    font-weight: 800;

    color: var(--navy);

    margin-bottom: 4px;

}



.section-subtitle {

    color: var(--muted);

    font-size: 14px;

    margin-bottom: 20px;

}



.gr-textbox, .gr-dropdown {

    border-radius: 14px !important;

}



textarea, input, select {

    border-radius: 14px !important;

}



label {

    color: var(--navy) !important;

    font-weight: 700 !important;

    font-size: 13px !important;

}



button.primary-btn {

    background: linear-gradient(135deg, var(--gold) 0%, #F2C94C 100%) !important;

    color: var(--navy) !important;

    border: none !important;

    border-radius: 16px !important;

    font-weight: 800 !important;

    font-size: 16px !important;

    padding: 14px 18px !important;

    box-shadow: 0 12px 24px rgba(212,160,23,0.28) !important;

}



button.primary-btn:hover {

    transform: translateY(-1px);

    box-shadow: 0 16px 30px rgba(212,160,23,0.35) !important;

}



.output-wrap {

    min-height: 600px;

}



.result-card {

    background: white;

    border-radius: 24px;

    border: 1px solid var(--border);

    padding: 28px;

    box-shadow: 0 16px 45px rgba(15,23,42,0.08);

    color: var(--text);

}



.result-card.warning {

    border-left: 6px solid #D4A017;

}



.result-topline {

    display: inline-block;

    background: var(--gold-soft);

    color: #8A6500;

    font-size: 12px;

    font-weight: 800;

    padding: 7px 12px;

    border-radius: 999px;

    text-transform: uppercase;

    letter-spacing: 0.05em;

    margin-bottom: 12px;

}



.result-card h2 {

    color: var(--navy);

    font-size: 30px;

    margin: 8px 0 20px 0;

}



.result-card h3 {

    color: var(--navy);

    margin-top: 24px;

    margin-bottom: 12px;

    font-size: 18px;

}



.summary-grid {

    display: grid;

    grid-template-columns: repeat(2, 1fr);

    gap: 14px;

    margin: 18px 0 22px 0;

}



.summary-grid div {

    background: #F8FAFC;

    border: 1px solid var(--border);

    border-radius: 16px;

    padding: 14px;

}



.label {

    display: block;

    color: var(--muted);

    font-size: 12px;

    font-weight: 700;

    margin-bottom: 5px;

    text-transform: uppercase;

    letter-spacing: 0.04em;

}



.timeline {

    border-left: 3px solid var(--gold);

    padding-left: 18px;

}



.timeline-item {

    display: flex;

    gap: 14px;

    align-items: flex-start;

    margin-bottom: 12px;

}



.timeline-time {

    min-width: 70px;

    color: var(--navy);

    font-weight: 800;

}



.timeline-task {

    color: #374151;

}



.strategy-box, .mission-box {

    background: #F8FAFC;

    border: 1px solid var(--border);

    border-radius: 18px;

    padding: 18px;

    margin-top: 18px;

}



.mission-box ul {

    margin: 0;

    padding-left: 20px;

}



.mission-box li {

    margin-bottom: 8px;

}



.footer-note {

    text-align: center;

    color: var(--muted);

    font-size: 13px;

    margin-top: 20px;

}



@media (max-width: 800px) {

    .hero-title {

        font-size: 34px;

    }



    #hero {

        padding: 34px 28px;

    }



    .summary-grid {

        grid-template-columns: 1fr;

    }

}

"""

with gr.Blocks(
    css=custom_css,
    title="AI Study Assistant | AI-Scholars Final Project"
) as app:
    gr.HTML("""

    <div id="hero">

        <div class="hero-badge">AI Study Assistant | AI-Scholars Final Project</div>

        <h1 class="hero-title">Plan smarter study sessions in seconds.</h1>

        <p class="hero-subtitle">

            Build a personalized study plan based on your subject, goal, time, difficulty,

            learning style, and stress level — designed to help students stay focused and get better results.

        </p>

    </div>

    """)

    with gr.Row(elem_id="main-panel"):
        with gr.Column(scale=1):
            gr.HTML("""

            <div class="input-card">

                <div class="section-title">Create Your Study Plan</div>

                <div class="section-subtitle">Enter a few details and get a focused, step-by-step session plan.</div>

            """)
            subject = gr.Textbox(label="Subject", placeholder="Biology, Math, History, Chemistry")
            goal = gr.Textbox(label="Study Goal", placeholder="Prepare for quiz on photosynthesis")
            time_available = gr.Textbox(label="Time Available", placeholder="60")
            difficulty = gr.Dropdown(["Easy", "Medium", "Hard"], label="Difficulty Level", value="Medium")
            learning_style = gr.Dropdown(
                ["Visual", "Practice-Based", "Verbal", "Reading/Writing"],
                label="Learning Style",
                value="Practice-Based"
            )
            current_stress = gr.Dropdown(["Low", "Medium", "High"], label="Stress Level", value="Medium")
            submit = gr.Button("Generate Study Plan", elem_classes="primary-btn")
            gr.HTML("</div>")

        with gr.Column(scale=1, elem_classes="output-wrap"):
            output = gr.HTML("""

            <div class="result-card">

                <div class="result-topline">Your plan will appear here</div>

                <h2>Ready when you are.</h2>

                <p>Fill in the form and generate a personalized study plan built around your time, goal, and learning style.</p>

            </div>

            """)

    gr.HTML("""

    <div class="footer-note">

        Built for students who want structure, focus, and better study results.

    </div>

    """)

    submit.click(
        study_assistant,
        inputs=[subject, goal, time_available, difficulty, learning_style, current_stress],
        outputs=output
    )

app.launch()